//
//  TableBarVC.m
//  ceshi
//
//  Created by jinyu on 2018/3/26.
//  Copyright © 2018年 jinyu. All rights reserved.
//

/*********************************************************************************
 1.VC.hidesBottomBarWhenPushed = YES;//跳转隐藏tabbar
 
 2.AppDelegate.h 引用
 #import "TableBarVC.h"
 @property (nonatomic, strong) TableBarVC *tabBarVC;

 3.
 self.window.rootViewController = self.tableBar;
 
 -(TableBarVC * )tableBar{
 
 if(!_tabBarVC){
 
 _tabBarVC = [[TableBarVC alloc]init];
 _tabBarVC.selectedIndex = 2;//停留的页面
 
 }
 return _tabBarVC;
 
 }
 
*********************************************************************************/

#import "TableBarVC.h"

@interface TableBarVC ()

@end

@implementation TableBarVC

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [UITabBar appearance].translucent = NO;
    
    [self createTabBar];
    [self createItem];

}

-(void)createTabBar{
    NSArray * nameArray = @[@"One",@"Two",@"Three",@"fore"];
    NSMutableArray * arr = [NSMutableArray array];
    
    for(int i = 0;i < nameArray.count;i++){
        NSString * strClass = [NSString stringWithFormat:@"%@ViewController",nameArray[i]];
        Class aclass =NSClassFromString(strClass);
        UIViewController * vc = [[aclass alloc]init];
        UINavigationController * nav = [[UINavigationController alloc]initWithRootViewController:vc];
        [arr addObject:nav];
    }
    
    self.viewControllers = arr;
}
-(void)createItem{
    
    UITabBarController * tab = self;
    
    tab.tabBar.tintColor = [UIColor blackColor];
    UIViewController * one =tab.viewControllers[0];
    one.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"标题1" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""]];

    UIViewController * two =tab.viewControllers[1];
    two.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"标题2" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""]];
    
    UIViewController * three =tab.viewControllers[2];
    three.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"标题3" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""]];
    UIViewController * four =tab.viewControllers[3];
    four.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"标题4" image:[UIImage imageNamed:@""] selectedImage:[UIImage imageNamed:@""]];

    

}





@end
